﻿// Mirco Töpfer

using System;
using pheidippides.logging.Interfaces;
using System.Collections.Generic;

namespace pheidippides.logging.Classes
{
    public class ConsoleOutLogger : ILogger
    {
        #region Public Methods

        public void ChangeLogLevel(LogLevel logLevel)
        {
            throw new NotImplementedException();
        }

        public void LogMessage(string message, LogLevel logLevel)
        {
            LogEntry currentEntry = new LogEntry(message, logLevel);

            String logEntryString = currentEntry.TimeStamp.ToShortDateString() + " " +
                                    currentEntry.TimeStamp.ToLongTimeString() + "." +
                                    currentEntry.TimeStamp.Millisecond.ToString("000") + "\t" +
                                    currentEntry.LogLevel + "\t" + currentEntry.Message;
            Console.WriteLine(logEntryString);

            if (OnNewLogEntry != null)
                OnNewLogEntry(currentEntry);
        }

        public void LogException(String message, Exception ex, LogLevel logLevel)
        {
            LogMessage(message + Environment.NewLine + ex.Message + Environment.NewLine + ex, logLevel);
        }

        public List<LogEntry> GetLogEntrys()
        {
            throw new NotImplementedException();
        }

        public string GetLastLogEntrysString()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Public Events

        public event NewLogEntry OnNewLogEntry;

        #endregion
    }
}